function Lua_modifier_item_mingyu_gudu(keys)
	PopupDamageOverTime(keys.target,50)
end

function Lua_XKH_D( keys )
	local caster = keys.caster
	local ability = keys.ability
	local healthregen = Round(0.025*caster:GetHealthDeficit(),0.01)*100
	caster:RemoveModifierByName("modifier_XKH_D_healthregen")
	ability:ApplyDataDrivenModifier(caster,caster,"modifier_XKH_D_healthregen",{})
	caster:SetModifierStackCount("modifier_XKH_D_healthregen",ability,healthregen)
end
function Lua_item_feiyannu_chuantou(keys)
	local attacker = keys.attacker
	local target = keys.target
	local ability = keys.ability
	if not target:IsHero() and not target:IsTower() then
		local attackdamage = attacker:GetAttackDamage()
		if attacker:IsRangedAttacker() then
			attackdamage = math.floor(attackdamage*0.15)
		else
			attackdamage = math.floor(attackdamage*0.25)
		end
		ability:ApplyDataDrivenModifier(attacker, attacker, "modifier_item_feiyannu_chuantou_1", {})
		attacker:SetModifierStackCount("modifier_item_feiyannu_chuantou_1", attacker, attackdamage)
	end
end

function Lua_item_chigangzhua_chizhua(keys)
	local attacker = keys.attacker
	local target = keys.target
	local ability = keys.ability
	if not target:IsMagicImmune() then
		ability:ApplyDataDrivenModifier(attacker, target, "modifier_item_chigangzhua_chizhua", {})
	end
end

function Lua_item_longyuan_chileiluo( keys )
	local speller = keys.caster
	local point = keys.target_points[1]
	local ability = keys.ability
	local time = -0.5
	GameRules:GetGameModeEntity():SetContextThink(DoUniqueString("chileiluo"),
	function()
		if time > 0 then
			local targets = FindUnitsInRadius(speller:GetTeam(), point, nil, 450, ability:GetAbilityTargetTeam(), ability:GetAbilityTargetType(), ability:GetAbilityTargetFlags(), FIND_CLOSEST, true)
			local particleID = ParticleManager:CreateParticle( "particles/units/heroes/hero_lina/lina_spell_light_strike_array.vpcf", PATTACH_WORLDORIGIN, speller)
			ParticleManager:SetParticleControl( particleID, 0, point)
			ParticleManager:SetParticleControl( particleID, 1, Vector( 450, 1, 1 ) )
			ParticleManager:ReleaseParticleIndex( particleID )
			EmitSoundOnLocationWithCaster( point, "Ability.LightStrikeArray", speller )
			for i,unit in pairs(targets) do
				local damageTable = {victim=unit,
					attacker=speller,
					damage=ability:GetSpecialValueFor("damagepersecond") / 2,
					damage_type=DAMAGE_TYPE_MAGICAL}
				ApplyDamage(damageTable)
			end
			if time >= 6 then
				return nil
			end
		end
		EmitSoundOnLocationWithCaster( point, "Ability.PreLightStrikeArray", speller )
		p1 = ParticleManager:CreateParticle("particles/units/heroes/hero_lina/lina_spell_light_strike_array_ray_team.vpcf", PATTACH_WORLDORIGIN, speller)
		ParticleManager:SetParticleControl( p1, 0, point )
		ParticleManager:SetParticleControl( p1, 1, Vector( 450, 1, 1 ) )
		ParticleManager:ReleaseParticleIndex( p1 )
		time = time + 0.5
		return 0.5
	end
	, 0.5)
end

function Lua_item_jinzuantiluqiang_zirunganquan( keys )
	local caster = keys.caster
	local ability = keys.ability
	if caster:GetHealthPercent() <= 20 then
		ability:ApplyDataDrivenModifier(caster, caster, "item_jinzuantiluqiang_zirunganquan_healthregen", {})
	else
		caster:RemoveModifierByName("item_jinzuantiluqiang_zirunganquan_healthregen")
	end
end

function Lua_item_leiguwengjinchui_manhengzhili( keys )
	local caster = keys.caster
	local target = keys.target
	local ability = keys.ability
	if UnitFilter(target, ability:GetAbilityTargetTeam(), ability:GetAbilityTargetType(), ability:GetAbilityTargetFlags(), caster:GetTeamNumber()) == UF_SUCCESS then
		ability:ApplyDataDrivenModifier(caster, target, "modifier_item_leiguwengjinchui_manhengzhili", {})
	end
end
function LuaApplyModifier( keys )
	local caster = keys.caster
	local ability = keys.ability
	local target
	if keys.TargetUnit == "TARGET" then
		target = keys.target
	elseif keys.TargetUnit == "ATTACKER" then
		target = keys.attacker
	elseif keys.TargetUnit == "UNIT" then
		target = keys.unit
	else
		target = keys.caster
	end
	local modifier_name = keys.ModifierName
	local duration = -1
	if keys.Duration then
		duration = keys.Duration
	end
	ability:ApplyDataDrivenModifier(caster, target, modifier_name, {duration=duration})
end
function Lua_CreateEffectTargetPoint ( keys )
	local point = keys.target_points[1]
	local particleID = ParticleManager:CreateParticle(keys.effect_name, PATTACH_POINT, keys.caster)
	ParticleManager:SetParticleControl(particleID,0,point)
end
function TestGravityFunc1(keys)
	local caster = keys.caster
	local target = keys.target
	local casterV = caster:GetAbsOrigin()
	local targetV = target:GetAbsOrigin()
	local direction = (casterV - targetV):Normalized()
	target:SetAbsOrigin(targetV+direction*3.0)
end
function TestGravityFunc2(keys)
end